package io.wins.vertx.entity;

import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import io.wins.vertx.utils.UUIDUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by colin on 2018/3/17.
 */

@DataObject(generateConverter = true)
public class Codelist {
    public final String id;
    public String bookName;
    public String code;
    public String name;

    public Codelist(final JsonObject json) {
        CodelistConverter.fromJson(json, this);
        this.id = StringUtils.isEmpty(json.getString("id")) ?
            UUIDUtils.genId() : json.getString("id");
    }

    public JsonObject toJson() {
        final JsonObject json = new JsonObject();
        CodelistConverter.toJson(this, json);
        return json;
    }

    public String getId() {
        return this.id;
    }

    public String getBookName() {
        return this.bookName;
    }

    public void setBookName(final String bookName) {
        this.bookName = bookName;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public String getName() {
        return this.name;
    }

    public void setName(final String name) {
        this.name = name;
    }
}
